#!/bin/bash
#
# Script to extract and plot the energy level of hydrogen atom from example 6
# You might need to modify this file if you have a different input/script
#
# Output from band calculation is a must
if [ ! -s "EIGENVAL" ]; then
   echo "File: EIGENVAL not found or empty!"
   exit
fi
#
# Extract energy level info
tail -8 EIGENVAL|awk '{printf "0. %lg %lg\n1 %lg %lg\n\n", $2, $3, $2, $3}' > .EngLevel.dat
#
# Script to draw the band structure
cat > .gnuplot.scr << EOF
set term post enha colo 20
set out 'hydrogen-EL.eps'

set xlabel ''
set ylabel 'Energy (eV)'

unset xtics
set ytics 5

set xr [0:1]
#set yr [-25:10]

#unset key
plot '.EngLevel.dat' u 1:2 w l t 'up', '' u 1:3 w l t 'down'

# output a png file
set term png enha trans truec
set out "hydrogen-EL.png"
replot

EOF
# gnuplot is employed to draw the figure
gnuplot .gnuplot.scr;  rm -rf .gnuplot.scr
# visualize the figure by using evince
evince hydrogen-EL.eps

exit 0
